<template>
    <div class="box">
        <div class="title">
            <p>未来七天旅客数量趋势图</p>
            <img src="../../images/dataScreen-title.png" />
        </div>
        <div class="charts" ref="chartsRef"></div>
    </div>
</template>

<script setup lang='ts'>
import * as echarts from 'echarts'
const chartsRef = ref()


onMounted(() => {
    let myChart = echarts.init(chartsRef.value);
    myChart.setOption({
        xAxis: {
            type: 'category',
            boundaryGap: false,
            splitLine: {
                show: false
            },
            data: ['周一', '周二', '周三', '周四', '周五', '周六', '周日'],
            axisTick: {
                show: true
            }
        },
        yAxis: {
            splitLine: {
                show: false
            },
            type: 'value',
            axisLine: {
                show: true
            },
            axisTick: {
                show: true
            }
        },
        grid: {
            left: 40,
            top: 15,
            right: 20,
            bottom: 20
        },
        tooltip: {  // 添加 tooltip 配置
            trigger: 'axis',
            show: true
        },
        series: [{
            type: 'line',
            data: [120, 1240, 66, 2299, 321, 890, 1200],
            smooth: true,
            areaStyle: {
                color: {
                    type: 'linear',
                    x: 0,
                    y: 0,
                    x2: 0,
                    y2: 1,
                    colorStops: [{
                        offset: 0, color: 'red' // 0% 处的颜色
                    }, {
                        offset: 1, color: 'blue' // 100% 处的颜色
                    }],
                    global: false // 缺省为 false
                }
            }
        }]

    })
})
</script>

<style scoped lang='scss'>
.box {
    width: 100%;
    height: 100%;
    background: url('../../images/dataScreen-main-lb.png') no-repeat;
    background-size: 100% 100%;

    .title {
        color: white;
        font-size: 20px;
        margin-left: 10px;
        margin-top: -10px;
    }

    .charts {
        height: calc(100% - 40px);
    }
}
</style>